/* 登录解劝 */
function loginDiss(){
    let login = sessionStorage.getItem("login")
    if(login != "true"){
        alert("请先登录");
        location.href = "../html/login.html"
    }
}
loginDiss()

/* 系统时间 */
function getTime(){
    setTime()
    setInterval(()=>{
        setTime()
    },1000)
}
getTime();

function setTime(){
    let d = new Date();
    let yea = d.getFullYear();
    let mon = d.getMonth()+1;
    let day = d.getDate();
    let hou = d.getHours();
    let min = d.getMinutes();
    let sec = d.getSeconds();
    document.querySelector("#headRight").innerHTML = `${yea}年${mon}月${day}日${hou}时${min}分${sec}秒`
}

/* 退出登录 */
function logout(){
    const quit = confirm("确定退出吗")
    if(quit){
        sessionStorage.removeItem("pageCurrent")
        sessionStorage.removeItem("annInfo")
        sessionStorage.removeItem("userInfo")
        sessionStorage.removeItem("login")
        sessionStorage.removeItem("goodstInfo")
        sessionStorage.removeItem("categoryInfo")
        sessionStorage.removeItem("studentInfo")
        sessionStorage.removeItem("currentPage")

        location.href = "../html/login.html"
    }
}

/* 管理者名字 */
let userInfo = sessionStorage.getItem("userInfo")
userInfo = JSON.parse(userInfo)
$("#glname").html(userInfo.mname)